package com.atguigu.my.chapter03

/**
 *
 * @description: xxx
 * @time: 2020-05-22 15:58
 * @author: baojinlong 
 **/
object CatDemo {


  def main(args: Array[String]): Unit = {
    val cat = new Cat
    cat.age = 10
    cat.color = "黄色"
    cat.name = "小花"
    printf("小猫name=%s 颜色=%s, 年龄=%d", cat.name, cat.color, cat.age)
    println("hello============")
    val list = List(1, 2, 3, 4, 5)
    list.foreach(myShow)
  }

  def myShow(n: Int): Unit = {
    println("我是" + n)
  }
}

/**
 * 一个类编译后变成了一个字节码文件.
 */
class Cat {
  var name: String = ""
  var age: Int = _
  var color: String = _

  def cal(n1: Int, n2: Int): Int = {
    n1 + n2
  }
}
